package com.yuhs.zixing.study.design.pattern.dp001.principle.p03.dependency.inversion;

/**
 * @description 依赖传递 setter
 * @author: yuhs
 * @date 2022/3/25 下午8:14
 */
public class DependencyPassDemo003 {
    public static void main(String[] args) {

        ChangHong3 changHong = new ChangHong3();
        OpenAndClose3 openAndClose = new OpenAndClose3();
        openAndClose.setTvInterface3(changHong);
        openAndClose.open();
    }
}

interface TVInterface3 {
    void play();
}

class ChangHong3 implements TVInterface3 {
    @Override
    public void play() {
        System.out.println("长虹电视播放西游记");
    }
}


interface OpenAndCloseInterface3 {
    void open();

    void setTvInterface3(TVInterface3 tvInterface3);
}

class OpenAndClose3 implements OpenAndCloseInterface3 {

    private TVInterface3 tvInterface3;

    @Override
    public void setTvInterface3(TVInterface3 tvInterface3) {
        this.tvInterface3 = tvInterface3;
    }

    @Override
    public void open() {
        tvInterface3.play();
    }


}
